Learning Objectives

After completing this lesson, you’ll be able to:

Instructions

In this lesson, you will:

Resources

Introduction

In this example, imagine you are a GIS technician working for a city planning department.

The team responsible for maintaining parks has a workspace that converts their data from the MapInfo TAB source format to Google KML. It also writes an XML metadata file to show who translated the data and when.

At the moment, they face two problems:

You have been assigned to help solve these problems. At least one of these requires creating user parameters to replace hard-coded values.

1) Open Starting Workspace

Starting workspace

The metadata part of the translation consists of the two transformers and an XML writer feature type.

The Sampler transformer ensures that only one record is written to the output metadata by discarding all but one feature, and the AttributeCreator creates a set of attributes to write to the metadata.

Sampler FME parameters

2) Change XML Writer Parameter

An FME parameter called Pretty Print controls the style of the XML file being written:

Viewing the Pretty Print parameter

To ensure the output is always well-formatted, we should set this parameter to Yes - but we won't create a user parameter from it because we don't want the end-user to change it.

Changing a writer parameter value

We have now changed an FME parameter as a workspace author.

3) Create a User Parameter

The output schema has three variable attributes: username, user company (organization), and user email. We should create a user parameter for each to allow the end-user to enter that information.

User Parameters > Manage User Parameters

Adding a Text parameter

Parameter Identifier UserNameParam
Label Enter your name
Required Enabled
Show Label Enabled

User parameter dialog filled out

4) Create Remaining User Parameters

The quickest way to create the other two required parameters (UserMailParam and UserCompanyParam) is to duplicate the UserNameParam parameter.

Duplicating an existing user parameter

Three user parameters

5) Use User Parameter – Method 1

Each user parameter we've just defined provides values we need to connect to attributes in the writer schema. There are several ways to extract the value for such a purpose, and we’ll use a different method for each parameter to illustrate the different methods.

Setting an attribute value to a user parameter

6) Use User Parameter – Method 2

A second way to extract the value from a user parameter is with a ParameterFetcher transformer.

ParameterFetcher transformer parameters

7) Use User Parameter – Method 3

Did you notice that the list of available parameters includes many FME-related system parameters? These are particularly useful when using FME Flow and for writing metadata, as we are here.

BuildNumber not receiving any values

Let's fix that.

Using an FME Parameter

BuildNumber will be written

8) Save and Run Workspace

Prompt for Parameters option

<?xml version="1.0" encoding="UTF-8"?>
<fme:xml-tables
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:fme="http://www.safe.com/xml/xmltables" xsi:schemaLocation="http://www.safe.com/xml/xmltables ParksMetadata.xsd">
    <fme:ParksMetadata-table>
        <fme:ParksMetadata>
            <fme:AuthorName>Bob User</fme:AuthorName>
            <fme:AuthorEmail>bob@safe.com</fme:AuthorEmail>
            <fme:AuthorCompany>Safe Software</fme:AuthorCompany>
            <fme:UpdateDate>2024-02-01</fme:UpdateDate>
            <fme:BuildNumber>23764</fme:BuildNumber>
        </fme:ParksMetadata>
    </fme:ParksMetadata-table>
</fme:xml-tables>